package com.lazy.tools;

import org.python.core.*;
import org.python.util.PythonInterpreter;

/**
 * Created by grind on 6/24/16.
 */
public class CallPython {

    public static void main(String[] argv) {
        PythonInterpreter interpreter = new PythonInterpreter();

        PySystemState sys = Py.getSystemState();
        System.out.println(sys.path.toString());

//        interpreter.exec("print 'hello'");

//        interpreter.exec("import sys");
//        interpreter.exec("print sys.path");
        interpreter.execfile("/home/grind/works/python/python_study/FirstDemo/src/logtest/test_log1.py");

        PyFunction func = (PyFunction)interpreter.get("adder",PyFunction.class);

        int a = 2010, b = 2 ;
        PyObject pyobj = func.__call__(new PyInteger(a), new PyInteger(b));
        System.out.println("anwser = " + pyobj.toString());
    }
}
